//公共组件 数量选择器
import './index.scss';
import React, { FC, ReactElement } from 'react';

interface IProps {
  count: number;
  setCount: (type: COUNT_TYPE) => void;
}

export enum COUNT_TYPE {
  PLUS = 'plus',
  MINUS = 'minus'
}

const Selector: FC<IProps> = ({ count, setCount }): ReactElement => {
  return (
    <div className="selector">
      <h2>选择数量：</h2>
      <button onClick={() => setCount(COUNT_TYPE.MINUS)}>-</button>
      <input type="text" readOnly value={count || 0} />
      <button onClick={() => setCount(COUNT_TYPE.PLUS)}>+</button>
    </div>
  );
};

export default Selector;
